using System.Transactions;

namespace KL.Standard.Model.Attribute;

/// <summary>
/// 同个事务的标签
/// </summary>
[AttributeUsage(AttributeTargets.Method, Inherited = true)]
public class RepoUseTranAttribute : System.Attribute
{
    /// <summary>
    /// 数据源的标识
    /// </summary>
    public string DataSourceTag { set; get; }

    /// <summary>
    /// 超时时间
    /// </summary>
    public int Timeout { get; set; }
    /// <summary>
    /// 事务范围
    /// </summary>
    public TransactionScopeOption ScopeOption { get; set; }
    /// <summary>
    /// 事务隔离级别
    /// </summary>
    public IsolationLevel IsolationLevel { get; set; }
    //public UnitOfWorkAttribute()
    //{
    //    Timeout = 60;
    //    ScopeOption = TransactionScopeOption.Required;
    //    IsolationLevel = IsolationLevel.ReadCommitted;
    //}
    /// <summary>
    /// 
    /// </summary>
    /// <param name="dsTagName">数据源标识</param>
    public RepoUseTranAttribute(string dsTagName)
    {
        DataSourceTag = dsTagName;
        Timeout = 60;
        ScopeOption = TransactionScopeOption.Required;
        IsolationLevel = IsolationLevel.ReadCommitted;
    }


}